package com.example.controller;

import com.example.service.Sender;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("rabbit")
public class RabbitMQController {

    private final Sender sender;

    public RabbitMQController(Sender sender, Sender sender1){

        this.sender = sender1;
    }

    @GetMapping("oneToOne")
    private ResponseEntity<HttpStatus> oneToOne(){
        System.out.println(sender.send("one to one"));
        return new ResponseEntity<>(HttpStatus.OK);
    }

    @GetMapping("oneToMany")
    private ResponseEntity<HttpStatus> oneToMany(){
        for (int i = 0; i < 10; i++) {
            System.out.println(sender.send("one to many"+i));
        }

        return new ResponseEntity<>(HttpStatus.OK);
    }
}
